package com.koron.css2.serviceManage.mapper;

import com.koron.css2.serviceManage.bean.PostBean;
import com.koron.css2.serviceManage.queryBean.PostQueryBean;
import com.koron.css2.serviceManage.vo.PostVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;
@EnvSource("_default")
public interface PostMapper {
    /**
     * 校验字段内容重复
     */
    @Select("select count(*) from pub_post where ${key} = #{val}")
    Integer check(@Param("key") String key, @Param("val") String val);

    /**
     * 校验字段内容重复-排除当前记录
     */
    @Select("select count(*) from pub_post where ${key} = #{val} and id <> #{id}")
    Integer check2(@Param("key") String key, @Param("val") String val, @Param("id") String id);

    Integer insertPost(PostBean bean);

    List<PostVo> selectPostList(PostQueryBean bean);

    @Select("select * from pub_post where id = #{id}")
    PostBean selectPostById(@Param("id") String id);

    Integer updatePost(PostBean bean);

}
